<?php
include_once 'model/banner/process.php';
include_once 'module/controls.php';
include_once 'model/user/user_create.php';
$c = new controls();
$banner = new banner();
$user = new users();
$fillByName = $user->FillOneByName($_SESSION);
$result = $banner->FillAllByTop();
$level_decode = json_decode($fillByName["level"], true);
?>
<div id="content">
    <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "") { ?>
        <span class="bglinkleft"><a class="link" href="<?= $url["home"] ?>/menu/banner-right"><?php echo $phrase["banner_right"] ?></a></span>
    <?php } ?>
    <?php if ($level_decode["admin"] != "" || $level_decode["create"] != "") { ?>
        <span class="bglink"><a class="link" href="<?= $url["home"] ?>/menu/banner-create"><?php echo $phrase["banner_create"] ?></a></span>
    <?php } ?>
    <table id="example" cellspacing="2" class="display">
        <tr>
            <th class="first"><?php echo $phrase["banner_url"] ?></th>
            <th width="80px"></th>
        </tr>
        <?php
        while ($rows = mysql_fetch_array($result)) {
            $i++;
            if ($i % 2) {
                ?>
                <tr class="gradeC odd">
                    <td style="text-align: left"><img src="<?php echo $rows["banner_url"] ?>" width="200" height="100"/></td>
                    <td>
                        <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "") { ?>
                            <a href="<?= $url["home"] ?>/menu/bannerupdate/id/<?php echo $rows["banner_id"] ?>">
                                <image src="<?= $url["home"] ?>/images/icons/edit-icon.gif"/>
                            </a>
                        <?php } ?>
                        <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "" && $level_decode["delete"]) { ?>
                            | 
                        <?php } ?>
                        <?php if ($level_decode["admin"] != "" || $level_decode["delete"] != "") { ?>
                            <a href="<?= $url["home"] ?>/menu/bannerdelete/id/<?php echo $rows["banner_id"] ?>" onclick="return confirm('Bạn có chắc chắn muốn xóa không.');">
                                <image src="<?= $url["home"] ?>/images/icons/b_drop.png"/>
                            </a>
                        <?php } ?>
                </tr>
            <?php } else { ?>
                <tr class="gradeC even">
                    <td style="text-align: left"><img src="<?php echo $rows["banner_url"] ?>" width="200" height="100"/></td>
                    <td>
                        <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "") { ?>
                            <a href="<?= $url["home"] ?>/menu/bannerupdate/id/<?php echo $rows["banner_id"] ?>">
                                <image src="<?= $url["home"] ?>/images/icons/edit-icon.gif"/>
                            </a>
                        <?php } ?>
                        <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "" && $level_decode["delete"]) { ?>
                            | 
                        <?php } ?>
                        <?php if ($level_decode["admin"] != "" || $level_decode["delete"] != "") { ?>
                            <a href="<?= $url["home"] ?>/menu/bannerdelete/id/<?php echo $rows["banner_id"] ?>" onclick="return confirm('Bạn có chắc chắn muốn xóa không.');">
                                <image src="<?= $url["home"] ?>/images/icons/b_drop.png"/>
                            </a>
                        <?php } ?>
                    </td>
                </tr>
            <?php } ?>
        <?php } ?>
    </table>
</div>
